/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function CreateXmlHttpObj()
{
	try
	{
		XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");

	}
	catch(e)
	{
		try
		{
			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpObj = null;
		}
	}
		if(!XmlHttpObj && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpObj = new XMLHttpRequest();
	}
}
function Combo_Anio(obj)
{

    CreateXmlHttpObj();

	if(XmlHttpObj)
	{
            XmlHttpObj.onreadystatechange =Inicia;
            XmlHttpObj.open("POST","XML_Mes.php",true);
            XmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            XmlHttpObj.send("anio="+obj);
        }
 }
function Inicia()
{
	if(XmlHttpObj.readyState == 4)
	{
		if(XmlHttpObj.status == 200)
		{
                        var Obj=XmlHttpObj.responseXML.documentElement;
                        var val=Obj.getElementsByTagName('Mes');
                        var tm=val.length;

                        var Mes_List = document.getElementById("Mes");
                        var Dia_List = document.getElementById("Dia");
                        var cmes = document.getElementById("cmes");
                        var cdia = document.getElementById("cdia");
                        if(Mes_List!=null)
                            {
                                cmes.removeChild(Mes_List);
                            }
                        if(Dia_List!=null)
                            {
                                cdia.removeChild(Dia_List);
                            }

                        if(tm>0){
                            
                            var art1=document.createElement('select');
                            art1.setAttribute('name','Mes');
                            art1.setAttribute('id','Mes');
                            //art1.setAttribute('onChange','Combo_Mes("++",Mes.Value)');
                            art1.onchange=function(){Combo_Mes(document.getElementById('Anio').value,document.getElementById('Mes').value);};
                            cmes.appendChild(art1);
                            Mes_List = document.getElementById("Mes");
                            for(var x=0;x<tm;x++)
                            {
                                var id1=val[x].childNodes[0].childNodes[0].nodeValue;
                                var id2=val[x].childNodes[1].childNodes[0].nodeValue;
                                var id3=val[x].childNodes[2].childNodes[0].nodeValue;
                                var optionItem;
                                optionItem = new Option( id2+" -- "+id3, id1,  false, false);
                                Mes_List.options[Mes_List.length] = optionItem;
                            }

                        }



//                            Combo_Mes(document.getElementById('Anio').value,document.getElementById('Mes').value)*/


		}
		else
		{
			alert("Codigo de error: "  + XmlHttpObj.status);
		}
	}
}
function CreateXmlHttpObj2()
{
	try
	{
		XmlHttpObj2 = new ActiveXObject("Msxml2.XMLHTTP");

	}
	catch(e)
	{
		try
		{
			XmlHttpObj2 = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpObj2 = null;
		}
	}
		if(!XmlHttpObj2 && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpObj2 = new XMLHttpRequest();
	}
}
function Combo_Mes(obj,obj2)
{

    CreateXmlHttpObj2();

	if(XmlHttpObj2)
	{
            XmlHttpObj2.onreadystatechange =Inicia2;
            XmlHttpObj2.open("POST","XML_Dia.php",true);
            XmlHttpObj2.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            XmlHttpObj2.send("anio="+obj+"&mes="+obj2);
        }
 }
function Inicia2()
{
	if(XmlHttpObj2.readyState == 4)
	{
		if(XmlHttpObj2.status == 200)
		{
                        var Obj=XmlHttpObj2.responseXML.documentElement;
                        var val=Obj.getElementsByTagName('Dia');
                        var tm=val.length;


                        var Dia_List = document.getElementById("Dia");
                        var cdia = document.getElementById("cdia");
                        if(Dia_List!=null)
                            {
                                cdia.removeChild(Dia_List);
                            }
                        if(tm>0){

                            var art2=document.createElement('select');
                            art2.setAttribute('name','Dia');
                            art2.setAttribute('id','Dia');
                            cdia.appendChild(art2);
                            Dia_List = document.getElementById("Dia");
                            for(var x=0;x<tm;x++)
                            {
                                var id1=val[x].childNodes[0].childNodes[0].nodeValue;
                                var id2=val[x].childNodes[1].childNodes[0].nodeValue;
                                var id3=val[x].childNodes[2].childNodes[0].nodeValue;
                                var optionItem;
                                optionItem = new Option( id2+" -- "+id3, id1,  false, false);
                                Dia_List.options[Dia_List.length] = optionItem;
                            }

                        }
                        /*var Dia_List = document.getElementById("Dia");
                        for (var count = Dia_List.options.length-1; count >-1; count--)
                        {
                            Dia_List.options[count] = null;
                        }
                        for(var x=0;x<tm;x++)
                            {
                                var id1=val[x].childNodes[0].childNodes[0].nodeValue;
                                var id2=val[x].childNodes[0].childNodes[0].nodeValue;
                                var optionItem;
                                optionItem = new Option( id2, id1,  false, false);
                                Dia_List.options[Dia_List.length] = optionItem;
                            }*/


		}
		else
		{
			alert("Codigo de error: "  + XmlHttpObj2.status);
		}
	}
}

function popup_vista_h(page){
             var opciones= "location=no,scrollbars=yes, directories=no,menubar=yes,\n\
                titlebar=no,toolbar=yes, status=no,top=80,left=150,rezisable=yes,fullscreen=yes";
             window.open(page, "", opciones);
         }


